<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // next方法可以传入参数，作为上个yield的返回结果
        function* gen(args) {
            console.log('args:', args)

            let r = yield 1;
            console.log('r: ', r)
            yield 2;
            yield 3;
        }

        let iter = gen('A');
        console.log(iter.next())
        console.log(iter.next('ddd'))
        console.log(iter.next())
        console.log(iter.next())

    </script>
</body>
</html>